<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <button>点击</button>
    <script>
        //全局范围，普通函数，定时器 this都指向window
        console.log(this);
        function fn(){
            console.log(this);
        }
        setTimeout(function(){
            console.log(this);
        },1000)

    
        var ob = {
            sayHi:function(){
                console.log(this);//输出object
                console.log(1);
                
            }
        }
        ob.sayHi();
        var btn = document.querySelector('button');
        btn.addEventListener('click',function(){
            console.log(this);//输出btn
        })

        function Fun(){
            console.log(this);
            console.log(123);
        }
        var fun = new Fun(); //输出fun
    </script>
</body>
</html>